<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>权限-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">权限</div>
		<div class="right">
		    <a href="__APP__/System/permissions_list_add" class="btn">添加权限</a>
		</div>
	</div>
	<div id="content">
		<div class="filter">
			<div class="filter-item">
				<div class="filter-title">权限类型：</div>
				<ul class="filter-order">
					<foreach name="types" item="vo">
					<li <if condition="$type_all eq $vo['type']">class="current"</if>><a href="__APP__/System/permissions_list/type_all/{$vo['type']}">{$vo['type']}</a></li>
					</foreach>
				</ul>
			</div>
		</div>
		<div class="table-scrollx">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td width="200">权限编号({$sum})</td>
					<td width="500">权限名称</td>
					<td>权限备注</td>
					<td width="116" style="min-width:116px;">管理</td>
				</tr>
				<foreach name="result" item="vo">
				<tr>
					<td>{$vo['name_num']}</td>
					<td>
						<span class='show'>{$vo['full_name']}</span>
						<span class="hide">
							<input type="text" class="form-control name_cn w200" val="{$vo['name_cn']}" value="{$vo['name_cn']}" autocomplete="off">
							<select class="name_detail w150" val="{$vo['name_detail']}" autocomplete="off">
								<option value="-10">无</option>
								<foreach name="name_detail_list" item="uo">
								<option value="{$uo['name1']}" <if condition="$uo['name1'] eq $vo['name_detail']">selected</if>>{$uo['name2']}</option>
								</foreach>
							</select>
							<span class="error-item">必填项</span>
						</span>					
					</td>
					<td>
						<span class='show'>{$vo['name_remark']}</span>
						<span class='hide'><input type="text" class="form-control name_remark w200" val="{$vo['name_remark']}" value="{$vo['name_remark']}" autocomplete="off"></span>
					</td>
					<td class="nowrap">
						<div class="link_div show">
							<a href="javascript:;" class="permissions_edit" data-toggle="tooltip" data-placement="left" title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
						</div>
						<div class="btn_div hide center">
							<button class="btn sub left" pid="{$vo['id']}">确定</button>
							<button class="btn btn-default cancle left ml5">取消</button>
						</div>
					</td>
				</tr>
				</foreach>
			</table>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function() {
	$(".permissions_edit").click(function(){
		var $parents = $(this).parents("tr");
		$parents.find(".hide").show();
		$parents.find(".show").hide();
	});

	$(".cancle").click(function(){
		var $parents = $(this).parents("tr"),
			name_cn = $parents.find(".name_cn"),
			name_remark = $parents.find(".name_remark"),
			name_detail = $parents.find(".name_detail");
		name_cn.val(name_cn.attr("val"));
		name_remark.val(name_remark.attr("val"));
		name_detail.val(name_detail.attr("val")).select2();
		$parents.find(".hide,.error-item").hide();
		$parents.find(".show").show();
	}); 
	
	$(".sub").click(function(){
		var $parents = $(this).parents("tr"),
			type_all = "{$type_all}",
			pid = $(this).attr("pid"),
			name_num = $parents.find(".name_num").val(),
			name_cn = $parents.find(".name_cn").val(),
			name_detail = $parents.find(".name_detail").val(),
			name_remark = $parents.find(".name_remark").val();

		if(name_cn=="" || /^\s+$/.test(name_cn)){
			$parents.find(".name_cn").nextAll(".error-item").show(); 
		}else{
			$.ajax({
				type:"POST",
				asnyc:true,
				dataType:"json",
				data:{"pid":pid,"name_num":name_num,"name_cn":name_cn,"name_detail":name_detail,"name_remark":name_remark,"type_all":type_all},
				url:"__APP__/System/permissions_list_doedit",
				success:function(data){
					if(data['msg']){
						success_pop(data['status'],data['msg'],2);
					}else{
						success_pop(data['status'],data['msg']);
					}
				}
			});
		}

	});
	$(".menu li:first").find("a").removeClass("arrow_down").end().find(".sub_menu").hide();
	
	$(".name_cn").focus(function(){
		$(this).nextAll(".error-item").hide();
	});
});
</script>
</body>
</html>